#pragma once


#include <string>


#include "def.h"


class Metadata
{

public:
    Metadata();
    ~Metadata();
    enum {DB_SQLITE=1};
    bool Open(int dbType = DB_SQLITE);
    void Close();
    // table
    bool MakeTable();
    void SetTableName(const std::string& name);
    // file
    int SelectFileInfo(const std::string& relative, StFileInfo & info);
    bool InsertFileInfo(StFileInfo* info, int size);
    bool UpdateFileInfo(StFileInfo* info, int size);
    bool SelectFileLatestPacket(int64_t& packet);

    // version 
    int SelectVersionInfo(const std::string& app, StVersionInfo& info);
    bool InsertVersionInfo(const StVersionInfo& info) ;
    bool UpdateVersionInfo(const StVersionInfo& info) ;

private:
    struct MetadataImpl;
    MetadataImpl* m_impl{ nullptr };
};

